// 个人思路：使用set进行建议去重，比较set.size 和 双指针 last - first 进行比较，相等表示本次无重复，不相等表示重复
// 缺点：每次比较都要使用new Set 生成空间，还要进行字符串切割，调用大量api，使得运行时间极长
var lengthOfLongestSubstring = function (s) {
    const length = s.length;
    let maxsize = 0;
    let first = 0;
    let last = 0;
    for (; first < length && s.length - first > maxsize; first++) {
        last = first;
        let newArray = new Set(s.slice(first, last));
        while (newArray.size == last - first) {
            last++;
            newArray = new Set(s.slice(first, last));
        }
        if (newArray.size > maxsize) {
            maxsize = newArray.size
        }
    }
    return maxsize

};